package knowse.app;

import java.util.ArrayList;

import android.database.Cursor;

import android.database.sqlite.SQLiteDatabase;

import android.util.Log;

import knowse.app.daos.DBHelper;

public class DataModel {

	public DataModel() {
	}

	public HeatMapData getHeatMap(MapDataType mapDataType) {
		//Opens db connection for reading
		SQLiteDatabase db = new DBHelper().getReadableDatabase();
		String sqlQuery;
		Cursor cursor;
		HeatMapData heatMapData = new HeatMapData();
		
		//Get data depending on MapDataType arg.
		switch (mapDataType) {
		case TESTFAILS_PER_PROJECT:
			sqlQuery = "SELECT ProjectName, SUM(NumTests),StartDate FROM TestStatus GROUP BY StartDate";
			cursor = db.rawQuery(sqlQuery, null);
			heatMapData = new HeatMapData();
			
			/*cursor.moveToFirst();
			while (!cursor.isAfterLast()){
				heatMapData.addRow(cursor.getString(0), (float)cursor.getInt(1));
				cursor.moveToNext();
			}*/
		
		default:
            Log.w("KnowSE", "MapDataType not found!");
            break;
		}

		return heatMapData;
	}
}
